using System;
using System.Collections.Generic;
using System.Text;
using MindFactorial.LaunchPoint.Common;

namespace MindFactorial.LaunchPoint.Runtime
{
    /// <summary>
    /// Represents LaunchPoint Runtime specific exception.
    /// </summary>
    [Serializable]
    public class LaunchPointRuntimeException : ApplicationException , System.Runtime.Serialization.ISerializable 
    {
        string _Message = null;

        /// <summary>
        /// Creates a new Runtime Exception
        /// </summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public LaunchPointRuntimeException(string format, params string[] args) : base(string.Format(format,args))
        {
            this._Message = string.Format(format, args);
            Logger.Log(this._Message);
        }

        /// <summary>
        /// This version of the constructor is specifically for desirialization o fthe exception
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        public LaunchPointRuntimeException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            _Message = info.GetString("_Message");
        }



        #region ISerializable Members

        void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            info.AddValue("_Message", Message);
        }

        #endregion
    }
}
